package com.tcp2.handler;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * Author: XWQ
 * Time: 2014/12/11 0011
 * Copyright (C) 2014 Xiamen Yaxon Networks CO.,LTD.
 */
@Service
public class TenantCacheService {

  /*  private ConcurrentMap<Long, TenantInfo> tenant2info = new ConcurrentHashMap<>();



    private class Time2TenantInfo {
        public long lastTime; //最后更新时间
        public TenantInfo tenantInfo;//企业信息
    }

    @Autowired
    private TenantDao tenantDao;


//    public TenantInfo getTenantByPlatformIdOldTid(String oldTid, Long platformId) {
//        if (oldTid == null || platformId == null) {
//            return null;
//        }
//
//        TenantInfo ti = null;
//        for (TenantInfo t : tenant2info.values()) {
//            if (oldTid.equals(t.getOldTid()) && platformId == t.getPlatformId()) {
//                ti = t;
//                break;
//            }
//        }
//
//        if (ti == null) {
//            Tenant t = tenantDao.getTenantByPlatformIdOldTid(Long.valueOf(oldTid),platformId);
//            if (t != null) {
//                ti = new TenantInfo();
//                ti.setId(t.getId());
//                //ti.setDistrictId(t.getDistrictId());
//                ti.setName(t.getName());
//                //ti.setContactPhone(t.getContactPhone());
//                //ti.setIndustry(t.getIndustry());
//                tenant2info.put(ti.getId(), ti);
//            }
//        }
//
//        return ti;
//    }


    public void putTenant(Tenant tenant) {
        TenantInfo ti = new TenantInfo();
        ti.setId(tenant.getId());
        //ti.setDistrictId(tenant.getDistrictId());
        ti.setName(tenant.getName());
        //ti.setContactPhone(tenant.getContactPhone());
        //ti.setIndustry(tenant.getIndustry());
        tenant2info.put(ti.getId(),ti);
    }*//*  private ConcurrentMap<Long, TenantInfo> tenant2info = new ConcurrentHashMap<>();



    private class Time2TenantInfo {
        public long lastTime; //最后更新时间
        public TenantInfo tenantInfo;//企业信息
    }

    @Autowired
    private TenantDao tenantDao;


//    public TenantInfo getTenantByPlatformIdOldTid(String oldTid, Long platformId) {
//        if (oldTid == null || platformId == null) {
//            return null;
//        }
//
//        TenantInfo ti = null;
//        for (TenantInfo t : tenant2info.values()) {
//            if (oldTid.equals(t.getOldTid()) && platformId == t.getPlatformId()) {
//                ti = t;
//                break;
//            }
//        }
//
//        if (ti == null) {
//            Tenant t = tenantDao.getTenantByPlatformIdOldTid(Long.valueOf(oldTid),platformId);
//            if (t != null) {
//                ti = new TenantInfo();
//                ti.setId(t.getId());
//                //ti.setDistrictId(t.getDistrictId());
//                ti.setName(t.getName());
//                //ti.setContactPhone(t.getContactPhone());
//                //ti.setIndustry(t.getIndustry());
//                tenant2info.put(ti.getId(), ti);
//            }
//        }
//
//        return ti;
//    }


    public void putTenant(Tenant tenant) {
        TenantInfo ti = new TenantInfo();
        ti.setId(tenant.getId());
        //ti.setDistrictId(tenant.getDistrictId());
        ti.setName(tenant.getName());
        //ti.setContactPhone(tenant.getContactPhone());
        //ti.setIndustry(tenant.getIndustry());
        tenant2info.put(ti.getId(),ti);
    }*/
}
